package com.prompt.SensorHandle;

import com.prompt.GlobalState;
import com.prompt.utils.TimeUtil;

import android.content.Context;
import android.util.Log;

/**
 * 加速度感应器处理
 * */
public class AcceHandler extends SensorBaseHandler{

	private static final String TAG = "AcceHandler";
	private final long[] pattern = {800, 150, 400, 130}; // OFF/ON/OFF/ON.
	public AcceHandler(Context context){
		super(context);
	}
	
	public Boolean proccess(float xLateral,float yLongitudinal,float zVertical){
		Boolean result = false;
		Log.i(TAG, "\n heading " + xLateral);
		Log.i(TAG, "\n pitch " + yLongitudinal);
		Log.i(TAG, "\n roll " + zVertical);
		
		if(xLateral < -6 || xLateral > 6 || yLongitudinal < -6 || yLongitudinal > 6){
			if(isNeedPro()){
				super.vibrate(pattern, 2);
				super.playVoice();
				result = true;
			}
			else{
				result = false;
			}
			
		}
		return result;
	}

}
